FROM mcr.microsoft.com/dotnet/core/runtime:2.2-stretch-slim AS base
WORKDIR /app

FROM mcr.microsoft.com/dotnet/core/sdk:2.2-stretch AS build
WORKDIR /src
COPY ["ESTAR.CommandService/ESTAR.CommandService.csproj", "ESTAR.CommandService/"]
COPY ["ESTAR.Infrastructure/ESTAR.Infrastructure.csproj", "ESTAR.Infrastructure/"]
RUN dotnet restore "ESTAR.CommandService/ESTAR.CommandService.csproj"
COPY . .
WORKDIR "/src/ESTAR.CommandService"
RUN dotnet build "ESTAR.CommandService.csproj" -c Release -o /app

FROM build AS publish
RUN dotnet publish "ESTAR.CommandService.csproj" -c Release -o /app

FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "ESTAR.CommandService.dll"]